# ACM Northern Thailand 2011
# Problem A: Elephant Show

# review by @neizod on July 25, 2011
# code	15:23
# debug	15:47
# fin	16:03

import re

def rerun(x, y):
	global apple
	if not 0 <= x < len(map[0]) or not 0 <= y < len(map):
		return
	if map[y][x] == 1:
		return
	else:
		apple += 1
		map[y][x] = 1
		rerun(x+1, y)
		rerun(x, y+1)
		rerun(x-1, y)
		rerun(x, y-1)

#############

while True:
	try:
		raw = input()
	except EOLError:
		break
	XY = re.split('\W+', raw)
	XY = [int(XY[0]), int(XY[1])]
	
	if XY == [0, 0]:
		break
	
	map = []
	for i in range(XY[1]):
		map.append([])
		raw = input()
		for j in range(XY[0]):
			if raw[j] == '.':
				map[i].append(0)
			elif raw[j] == '#':
				map[i].append(1)
			else:
				map[i].append(0)
				SXY = j, i
	
	apple = 0
	rerun(SXY[0], SXY[1])
	print(apple)